<template>
	<view class="container">
		<top-back-navbar position="fixed" :title="title" background="#001b4d" color="#ffff"></top-back-navbar>
		<view class="big_title f-w-700">资产数据</view>
		<!-- <view class="cz-box">
			<view class="cz-number">¥{{userInfo.credit2 || '0.00'}}</view> 
			<view class="cz-text">可用资金</view>
		</view> -->
		<view>
			<block v-for="(item,index) in res" :key="index">
				<view class="cz-list-cell" hover-class="uni-list-cell-hover">
					<view class="cz-triplex-list">
						<text class="cz-name">{{item.pay_info}}</text>
						<text class="cz-jine">{{item.money}}</text>
					</view>
					<view class="cz-triplex-list">
						<text class="cz-time">{{item.time}}</text>
						<text class="cz-num">{{item.charge_status}}</text>
					</view>
				</view>
			</block>
		</view>
		<view v-if="res.length == 0" style="padding-top: 300upx;">
			<image src="/static/searchlist.png" mode=""
				style="display: block;margin: 0 auto;width: 240upx;height: 240upx;"></image>
			<view style="text-align: center;color: #999;">暂时没有任何记录</view>
		</view>
		<!-- <uni-load-more v-if="load == 1" :loadingType="loadingType" :contentText="contentText"></uni-load-more> -->
	</view>
</template>

<script>
	import uniLoadMore from '../../../components/uni-load-more.vue'
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				res: [],
				cointitle: ' ',
				index: 2,
				loadingType: 0,
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多了"
				},
				systemInfo: {},
				load: 0,
				openid: '',
				userInfo: '',
				title: '',
				pageInfo: {
					'dj': {
						title: '冻结钱包',
						path: '',
						query: {}
					},
					'th': {
						title: '提货券',
						path: '',
						query: {}
					},
					'bz': {
						title: '贝值',
						path: '/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=tzz.bz_list&app=1',
						query: {}
					},
					'xb': {
						title: '小贝',
						path: '',
						query: {}
					},
					'gz': {
						title: '股值',
						path: '/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=tzz.tzz_list&app=1',
						query: {}
					},
					'gq': {
						title: '股券',
						path: ''
					},
					'xfz': {
						title: '积分值',
						path: '/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=tzz.jfz_list&app=1',
						query: {}
					},
					'xfq': {
						title: '积分券',
						path: '',
						query: {}
					},
					'szz': {
						title: '数字资产',
						path: '',
						query: {}
					},
					'xbhq': {
						title: '小贝获取明细',
						path: '/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=tzz.dj_three&app=1',
						query: {
							type: 2
						}
					},
					'xbsf': {
						title: '小贝释放明细',
						path: '/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=tzz.zcz_out&app=1',
						query: {}
					}
				}
			};
		},
		onLoad: function(e) {
			const type = e.type;
			this.pageType = type;
			this.title = this.pageInfo[type].title;
			this.$GetOpenid().then(res=>{
				this.openid=res;
				this.setAjax()
			})
		},
		methods: {
			setAjax() {
				var data = {
					...this.pageInfo[this.pageType].query,
					'openid': this.openid,
				}
				uni.request({
					url: this.$BASE_URL + this.pageInfo[this.pageType].path,
					method: 'POST',
					data: data,
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					success: res => {
						console.log(res)
						let list = [];
						if (this.pageType == 'xfz') {
							list = Array.isArray(res.data.log) ? res.data.log : [];
							list.forEach(item => {
								item.pay_info = '积分值';
								item.money = item.num;
								item.time = item.time;
								item.charge_status = item.remark;
							})
						}
						if (this.pageType == 'gz') {
							list = Array.isArray(res.data.log) ? res.data.log : [];
							list.forEach(item => {
								item.pay_info = '股值';
								item.money = item.num;
								item.time = item.time;
								item.charge_status = item.remark;
							})
						}
						if (this.pageType == 'bz') {
							list = Array.isArray(res.data.log) ? res.data.log : [];
							list.forEach(item => {
								item.pay_info = '贝值';
								item.money = item.num;
								item.time = item.time;
								item.charge_status = item.remark;
							})
						}

						if (this.pageType == 'xbhq') {
							list = Array.isArray(res.data.list) ? res.data.list : [];
							list.forEach(item => {
								item.pay_info = '小贝获取';
								item.money = item.num;
								item.time = item.time;
								item.charge_status = item.remark;
							})
						}
						if (this.pageType == 'xbsf') {
							list = Array.isArray(res.data.out_log) ? res.data.out_log : [];
							list.forEach(item => {
								item.pay_info = '小贝释放';
								item.money = item.num;
								item.time = item.time;
								item.charge_status = item.common;
							})
						}
						this.res = list;
					},
					fail: () => {},
					complete: () => {}
				});
			}
		},
		onPullDownRefresh() {
			this.setAjax();
		},
		onReachBottom() {
			if (this.loadingType !== 0) {
				return;
			}
			this.loadingType = 1;
			uni.request({
				url: this.$BASE_URL +
					'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.log.get_list&app=1&page=' +
					this.index,
				method: 'POST',
				data: {
					'openid': this.openid
				},
				header: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
				success: res => {
					if (res.data.result.list.length == 0) {
						this.loadingType = 2;
						return;
					}
					this.res = this.res.concat(res.data.result.list)
					this.loadingType = 0;
					this.index = this.index + 1;
				},
				fail: () => {},
				complete: () => {}
			});

		},
	}
</script>

<style lang="scss">
	.status {
		width: 100%;
		font-size: 24upx;
		background: #e0e0e0;
		text-align: center;
		color: #fff;
		margin-top: 21upx;
	}

	page {
		background-color: #f2f5fa;
		box-sizing: border-box;
	}

	.container {
		padding: 0 30rpx 30rpx 30rpx;
		height: 100%;
	}

	.big_title {
		font-size: 32rpx;
		color: #1e1310;
		font-weight: 600;
		padding: 20rpx 30rpx 10rpx 0;
	}

	.cz-box {
		border-radius: 20rpx;
		padding: 30rpx;
		background: #001b4d;

		.cz-number {
			font-size: 46rpx;
			font-weight: bold;
			color: #fff;
			text-align: center;
		}

		.cz-text {
			font-size: 24rpx;
			font-weight: bold;
			color: #fff;
			text-align: center;
		}
	}

	.cz-list-cell {
		padding: 30rpx;
		border-radius: 20rpx;
		box-shadow: 0px 2px 8px 3px rgba(235,235,235,0.4);;
		padding: 20rpx 30rpx;
		margin-top: 30rpx;
		background-color: #fff;

		.cz-triplex-list {
			height: 50rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
		}

		.cz-name {
			font-size: 28rpx;
			font-weight: 600;
			color: #1e1310;
		}

		.cz-jine {
			font-size: 28rpx;
			font-weight: 600;
			color: #c30004;
		}

		.cz-time,
		.cz-num {
			font-size: 24rpx;
			color: #888889;
		}
	}
</style>
